<template>
  <div class="index-honor sub-margin">
    <!-- <div class="sub-page-title">评议栏</div> -->
    <div class="content">
      <div class="search-box">
        <el-menu
          size="small"
          :default-active="activeCode"
          class="search-menu-box"
          mode="horizontal"
          @select="onMenuClick">
          <el-menu-item v-for="(item, key) in menuInfo" :key="key" :index="key">
            {{ item.label }}
          </el-menu-item>
        </el-menu>
      </div>
      <div class="table-con" v-if="dataList.length">
        <div class="left-con">
          <AppraistPageType
            :evaluateType="menuInfo[activeCode].status"
            :dataList="dataList"
            @commentChange="commentChange" />
        </div>
        <div class="right-con">
          <AppraistPageTypeCon
            :userListData="userListData"
            :evaluateNeedId="evaluateNeedId"
            :evaluateType="menuInfo[activeCode].status" />
        </div>
      </div>
      <div class="table-con" v-else>
        <empty></empty>
      </div>
    </div>
  </div>
</template>

<script>
import AppraistPageType from './components/AppraistPageType'
import AppraistPageTypeCon from './components/AppraistPageTypeCon'
import { getCommentData } from '@apis/evaluation.js'
import Empty from '@com/Empty.vue'
export default {
  name: 'indexEvaluate',
  components: { AppraistPageType, AppraistPageTypeCon, Empty },
  props: {},
  data() {
    return {
      menuInfo: {
        start: {
          label: '待评议',
          status: '0',
        },
        end: {
          label: '已评议',
          status: '1',
        },
      },
      activeCode: 'start',
      dataList: [],
      // 评价人员列表
      userListData: [],
      evaluateNeedId: '',
    }
  },
  watch: {},
  computed: {},
  created() {
    this.getCommentBar()
  },
  mounted() {},
  methods: {
    onMenuClick(code) {
      this.activeCode = code
      this.userListData = []
      this.getCommentBar()
    },
    // 获取评价列表
    async getCommentBar() {
      const code = this.menuInfo[this.activeCode].status
      const { status, data } = await getCommentData(code)
      if (status === 200) {
        this.dataList = data || []
      }
    },
    // 左侧评价列表切换
    commentChange(index) {
      if (this.dataList.length) {
        this.evaluateNeedId = this.dataList[index].needDealId
        this.userListData = this.dataList[index].userStatusVOS
      } else {
        this.evaluateNeedId = ''
        this.userListData = []
      }
    },
  },
}
</script>
<style lang="scss" scoped>
@import '@styles/layout.scss';
.index-honor {
  height: 100%;
  .content {
    // height: calc(100% - 78px);
    height: calc(100%);
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    .search-box {
      width: 100%;
      margin-bottom: 20px;
      .el-menu {
        .is-active {
          font-weight: bold;
          font-size: 16px;
        }
      }
    }
    .table-con {
      flex: 1;
      display: flex;
      align-items: stretch;
      // padding: 20px 0;
      height: calc(100% - 50px);
      .left-con {
        width: 300px;
        height: 100%;
        overflow: auto;
        position: relative;
        border-right: 1px solid #e4eaf0;
      }

      .right-con {
        flex: 1;
        width: 100%;
        max-width: 1200px;
        margin: 0 auto;
        margin-left: 20px;
        position: relative;
        display: flex;
        flex-direction: column;
      }
    }
  }
}
</style>
